apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: httproute-hostname-intersection
  namespace: gateway-conformance-infra
spec:
  gatewayClassName: "{GATEWAY_CLASS_NAME}"
  listeners:
  - name: listener-1
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: Same
    hostname: very.specific.com
  - name: listener-2
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: Same
    hostname: "*.wildcard.io"
  - name: listener-3
    port: 80
    protocol: HTTP
    allowedRoutes:
      namespaces:
        from: Same
    hostname: "*.anotherwildcard.io"
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: specific-host-matches-listener-specific-host
  namespace: gateway-conformance-infra
spec:
  parentRefs:
  - name: httproute-hostname-intersection
    namespace: gateway-conformance-infra
  hostnames:
  - non.matching.com
  - "*.nonmatchingwildcard.io"
  - very.specific.com  #  matches listener-1's specific host
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /s1
    backendRefs:
    - name: infra-backend-v1
      port: 8080
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: specific-host-matches-listener-wildcard-host
  namespace: gateway-conformance-infra
spec:
  parentRefs:
  - name: httproute-hostname-intersection
    namespace: gateway-conformance-infra
  hostnames:
  - non.matching.com
  - wildcard.io
  - foo.wildcard.io  #  matches listener-2's wildcard host
  - bar.wildcard.io  #  matches listener-2's wildcard host
  - foo.bar.wildcard.io  #  matches listener-2's wildcard host
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /s2
    backendRefs:
    - name: infra-backend-v2
      port: 8080
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: wildcard-host-matches-listener-specific-host
  namespace: gateway-conformance-infra
spec:
  parentRefs:
  - name: httproute-hostname-intersection
    namespace: gateway-conformance-infra
  hostnames:
  - non.matching.com
  - "*.specific.com"  # matches listener-1's specific host
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /s3
    backendRefs:
    - name: infra-backend-v3
      port: 8080
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: wildcard-host-matches-listener-wildcard-host
  namespace: gateway-conformance-infra
spec:
  parentRefs:
  - name: httproute-hostname-intersection
    namespace: gateway-conformance-infra
  hostnames:
  - "*.anotherwildcard.io"  # matches listener-3's wildcard host
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /s4
    backendRefs:
    - name: infra-backend-v1
      port: 8080
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: no-intersecting-hosts
  namespace: gateway-conformance-infra
spec:
  parentRefs:
  - name: httproute-hostname-intersection
    namespace: gateway-conformance-infra
  hostnames:
  - specific.but.wrong.com
  - wildcard.io
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /s5
    backendRefs:
    - name: infra-backend-v2
      port: 8080
